<template>
	<div class="animate__animated animate__fadeIn">
    <div class="flexc" style="margin-bottom: 20px;">
      <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>组织名称</div>
      <div><el-input v-model="all.orgName" style="width: 350px; margin-left: 30px;" placeholder="请输入组织名称"></el-input></div>
    </div>
    <div class="flexc" style="margin-bottom: 20px;">
      <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>联系人</div>
      <div><el-input v-model="all.contact" style="width: 350px; margin-left: 30px;" placeholder="请输入联系人"></el-input></div>
    </div>
    <div class="flexc" style="margin-bottom: 20px;">
      <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>手机号</div>
      <div><el-input v-model="all.phone" style="width: 350px; margin-left: 30px;" placeholder="请输入手机号"></el-input></div>
    </div>
    <div style="padding-left: 130px;">
      <el-button type="primary" @click="add">确定</el-button>
    </div>

	</div>
</template>

<script>
  import { addorg,updateorg,getorg } from '@/api/xitong'
	export default {
		name: 'zuzhiguanli',

		data() {
			return {
        all:{
          "orgId":"",
          "orgName":"",
          "contact":"",
          "phone":""
        }
			}
		},
		created() {

      if(this.$store.state.showwho.value){
          this.bianji(this.$store.state.showwho)
      }
      if(this.$store.state.showwho.what == 'add'){
          this.logshow()
      }

		},
		mounted() {

		},
		methods: {


      bianji:function(item){
        let url = '/api/org/get/'+item.value
        getorg(url).then((response)=>{
          item = response.data
          this.all = {
            "orgId":item.orgId,
            "orgName":item.orgName,
            "contact":item.contact,
            "phone":item.phone
          }
        })
      },
      logshow:function(){
        this.all = {
          "orgId":"",
          "orgName":"",
          "contact":"",
          "phone":""
        }
      },
      add:function(){
        if(!this.all.orgName || !this.all.contact || !this.all.phone){
          this.$message.error('请填写完整参数');
          return
        }
        if(this.all.orgId){
          updateorg(this.all).then((response)=>{
            this.$message.success('修改成功');
            this.$emit('gengxin')
          })
        }else{
          addorg(this.all).then((response)=>{
            this.$message.success('新增成功');
            this.$emit('gengxin')
          })
        }
      }
		}
	}
</script>


<style scoped >

</style>
